<template>
  <div class="wrapper">
    <!-- <Anchor :labelList="labels" activeId="row-01" labelWidth="100">
      <div class="line" id="row-01">
        <CasePlanInfoBase v-model="value" />
      </div>
      <div class="line" id="row-02">
        <CaseExecuteInfoBase v-model="value" />
      </div>
      <div class="line" id="row-03">
        <CaseSummaryInfoBase v-model="value" />
      </div>
      <div class="line" id="row-04">
        <BusinesOpinions v-model="value" />
      </div>
      <div class="line" id="row-05">
        <HistorySH v-model="value" />
      </div>
    </Anchor>-->
    <BreakSpace :label="labels[0].title" :containerStyle="{ marginBottom: '10px' }" />
    <CasePlanInfoBase v-model="value" />
    <BreakSpace :label="labels[1].title" :containerStyle="{ marginBottom: '10px' }" />
    <CaseExecuteInfoBase v-model="value" />
    <BreakSpace :label="labels[2].title" :containerStyle="{ marginBottom: '10px' }" />
    <CaseSummaryInfoBase v-model="value" />
    <BreakSpace :label="labels[3].title" :containerStyle="{ marginBottom: '10px' }" />
    <ReportInfoBase v-model="value" />
    <BreakSpace :label="labels[4].title" :containerStyle="{ marginBottom: '10px' }" />
    <BusinesOpinions v-model="value" />
    <BreakSpace :label="labels[5].title" :containerStyle="{ marginBottom: '10px' }" />
    <HistorySH v-model="value" />
    <div class="dialogBottmView">
      <el-button @click="closeDialog">关 闭</el-button>
      <el-button
        @click="withdraw"
        :loading="saveLoading"
        type="primary"
      >撤回</el-button>
    </div>
  </div>
</template>

<script>
import { authority } from '@/utils/authMixin';
import { dictionary } from '@/utils/dictMixin';
import CasePlanInfoBase from './CasePlanInfoBase'; //项目计划信息
import CaseExecuteInfoBase from '../../oemInquire/CaseExecuteInfoBase'; //项目执行信息
import CaseSummaryInfoBase from '../../oemInquire/CaseSummaryInfoBase'; //项目总结材料
import ReportInfoBase from '../../oemInquire/ReportInfoBase'; //项目报备信息
import BusinesOpinions from '../../oemInquire/BusinesOpinions'; //事业部意见
import HistorySH from '../../oemInquire/HistorySH'; //历史审核记录
import { porjectWithdraw} from '@/api/cms-api/projectOperating/plan';

export default {
  mixins: [authority, dictionary],
  components: {
    CasePlanInfoBase,
    CaseExecuteInfoBase,
    CaseSummaryInfoBase,
    ReportInfoBase,
    BusinesOpinions,
    HistorySH
  },
  props: {
    value: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      labels: [
        { title: '项目计划信息', id: 'row-01' },
        { title: '项目执行信息', id: 'row-02' },
        { title: '项目总结材料', id: 'row-03' },
        { title: '项目报备信息', id: 'row-04' },
        { title: '事业部意见', id: 'row-05' },
        { title: '历史审核记录', id: 'row-06' }
      ]
    };
  },
  methods: {
    //保存
    saveDialog() {
      this.$emit('close', { visible: false });
    },
    // 撤回
    async withdraw(){
        
        let row = this.value.row;
        let status = row.planStatus;
        let planId = row.planId;//记录的主键
        if(status!="25311008"){//总结已提交
            this.$notify.error({title: '提示信息',message:'您好，只能撤回已提交的总结！'});
            return;
        } 
        
        this.$confirm('是否撤回', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
        }).then(async() => {
                let params = {
                      planId:planId,
                      type:"summary"
                  }
                  let res =  await porjectWithdraw(params);
                this.validReturnDate(res);
        }).catch(() => {
            this.$notify.info({title: '提示信息',message:'操作取消！'});
        });
    }, 
    validReturnDate(res){
          if (res.resultCode === 200) {
              this.$notify.success({title: '提示信息',message:'操作成功!'});
              this.closeDialog('refresh');
          }else {
              this.$notify.error({title: '提示信息',message:res.errMsg||'操作失败!'});
              
          }
      },
    //取消操作
    closeDialog() {
      this.$emit('close', { visible: false });
    }
  }
};
</script>
<style scoped>
.wrapper {
  height: calc(100vh - 110px);
}
</style>
